#e
#Title[zNu̖Sv]
#Text[ɈӖ̂ȂZtpfBB
]
#ScriptVersion[2]

script_enemy_main
{
	let scroll=0;
	let flag=0;
	let cx=GetCenterX();
	let cy=GetCenterY();
	let boss=GetCurrentScriptDirectory~"img\boss7-2.png";
	let eye=GetCurrentScriptDirectory~"img\bg7-1.png";
	let asa=GetCurrentScriptDirectory~"img\bg7-2.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetLife(1500);
		SetDamageRate(10,0);
		SetInvincibility(120);
		LoadGraphic(boss);
		LoadGraphic(eye);
		SetEffectForZeroLife(60,100,2);
		shottask;
		shottask2;
		drawtask;
		bombtask;
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
		SetShotAutoDeleteClip(64,64,64,64);
		DeleteGraphic(boss);
		DeleteGraphic(eye);
		DeleteGraphic(asa);
	}
	@DrawLoop
	{
		SetTexture(boss);	
		if(flag==1)
		{
			SetGraphicRect(52,0,81,63);
		}
		else if(flag==2)
		{
			SetGraphicRect(24,0,52,63);
		}
		else
		{
			SetGraphicRect(0,0,24,63);
		}
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetX,GetY);
	}
	@BackGround
	{
		SetColor(128,128,128);
		SetTexture(eye);	
		SetGraphicRect(0,0,384,448);
		SetAlpha(255);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx,cy);
		SetColor(255,255,255);
		SetTexture(asa);	
		SetGraphicRect(0,0,888,189*5);
		SetAlpha(64);
		SetGraphicScale(0.5,0.75);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx+scroll,cy);
		DrawGraphic(cx+scroll-444,cy);
		if(scroll>444)
		{
			scroll=0;
		}
	}
	task shottask
	{
		let s=0;
		let s2=1;
		SetShotAutoDeleteClip(64,512,64,64);
		SetMovePosition02(cx,-120,0);
		wait(60);
		SetMovePosition02(cx,cy-120,60);
		wait(120);
		SetScore(30000);
		SetTimer(120);
		CutIn(YOUMU,"zNu̖Sv",0,0,0,0,0);
		wait(120);
		loop
		{
			if(GetEnemyLife>1125)
			{
				wait(30);
				shot(s,s2,rand(30,90),1);
				wait(30);
				shot(s,s2,rand(30,90),0);
			}
			if(GetEnemyLife<=1125&&GetEnemyLife>750)
			{
				wait(20);
				shot(s,s2,rand(30,90),1);
				wait(20);
				shot(s,s2,rand(30,90),0);
			}
			if(GetEnemyLife<=750&&GetEnemyLife>375)
			{
				loop(2)
				{
					wait(5);
					shot(s,s2,rand(30,90),1);
				}
				loop(2)
				{
					wait(5);
					shot(s,s2,rand(30,90),0);
				}
				wait(45);
			}
			if(GetEnemyLife<=375)
			{
				loop(4)
				{
					wait(3);
					shot(s,s2,rand(30,90),1);
				}
				loop(4)
				{
					wait(3);
					shot(s,s2,rand(30,90),0);
				}
				wait(50);
			}
			if(GetTimer<30)
			{
				loop(5)
				{
					wait(3);
					shot(s,s2,rand(30,90),1);
				}
				loop(5)
				{
					wait(3);
					shot(s,s2,rand(30,90),0);
				}
				wait(50);
			}
		}
	}
	task shottask2
	{
		let s=0;
		let angle=0;
		let w=120;
		wait(300);
		loop
		{
			angle=rand(0,360);
			loop(36)
			{
				CreateShotA(s,GetX,GetY,0);
				SetShotDataA(s,0,5,angle,0,-0.1,1.5,117);
				FireShot(s);
				angle-=10;
			}
			if(GetEnemyLife>1125)
			{
				w=120;
			}
			if(GetEnemyLife<=1125&&GetEnemyLife>750)
			{
				w=90;
			}
			if(GetEnemyLife<=750&&GetEnemyLife>375)
			{
				w=60;
			}
			if(GetEnemyLife<=375)
			{
				w=45;
			}
			if(GetTimer<30)
			{
				w=30;
			}
			wait(w);
		}
	}
	task drawtask
	{
		let x=0;
		loop
		{	
			if(GetX>x+0.5)
			{
				flag=1;
			}
			else if(GetX<x-0.5)
			{
				flag=2;
			}
			else
			{
				flag=0;
			}
			x=GetX;
			scroll++;
			yield;
		}
	}
	task bombtask
	{
		loop
		{
			if(OnBomb)
			{
				SetAlpha(64);
				SetDamageRate(0,0);
			}
			else
			{
				SetAlpha(255);
				SetDamageRate(15,0);
				SetCollisionA(GetX(),GetY(),24);
			}
			yield;
		}
	}

	function shot(let shotid,let shotid2,let shottime,let right)
	{
		let long =48;
		let speed=0;
		let po =0;
		let point=0;
		let r=90;
		let angle=0;
		let carb=0;
		let time=shottime;
		if(right==1)
		{
			point=GetClipMaxX+32;
			angle=rand(220,260);
			carb=rand(-1,0);
		}
		else
		{
			point=GetClipMinX-32;
			angle=rand(320,280);
			carb=rand(1,0);
		}
		CreateLaserC(shotid,point,cy+rand(-90,90),10,long,WHITE01,0);
		SetLaserDataC(shotid,0,6,angle,carb,0,2);
		loop(9)
		{
			CreateShotA(shotid2,0,0,0);
			SetShotDataA(shotid2,0,0,90,0,0,3,250);
			SetShotDataA(shotid2,shottime-time,0,rand(260,280),0,0,3,52);
			SetShotDataA(shotid2,shottime-time+10,0,rand(85,95),0,0.1,rand(2,2.5)+speed,52);
			AddShot(time,shotid,shotid2,48);	
			time-=6;
			speed-=0.03;
		}
		SetShotKillTime(shotid,shottime);
		FireShot(shotid);
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}